package inherit;

public class Test {
    public  static  void main(String[] args){
        Student s1=new Student(23,"孙悟空","201702","二年级");
        s1.eat();
        s1.study();
        s1.sleep();
        System.out.println(s1.toString());
        Student s2=new Student();
        s2.setAge(23);
        s2.setName("猪八戒");
        System.out.println(s2.toString());
        System.out.println(s2.getName());
        person p=s1;//里氏代换 父类引用子类对象（子类不能引用父类对象）
        //p.study() 不存在
        System.out.println(p.toString());//toString()为子类的方法
//        person p2=new person();//父类引用父类对象
//        p2.setAge(100);p2.setName("如来佛祖");
//        System.out.println(p2.toString());
//        person p1=new Student();
//        person p2=new Employee();
//        p1.study();
//        p2.study();
        Student p1=new Student();
        p1.study();

    }

}
